#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;
stack<int> s1;
int main() {
    vector<string> a;
    string str;
    while(getline(cin, str, '.')) {
        a.push_back(str);
    }
    for(auto& s : a) {
        int ret = 0;
        for(int i = 0; i < s.size(); i++) {
            if(s[i] >= '0' && s[i] <= '9') {
                ret = ret * 10 + (s[i] - '0');
                if(i == s.size() - 1) {
                    s1.push(ret);
                }
            }else {
                if(s[i] == '-') {
                    int x = s1.top();
                    s1.pop();
                    int y = s1.top();
                    s1.pop();
                    s1.push(y - x);
                }else if(s[i] == '*') {
                    int x = s1.top();
                    s1.pop();
                    int y = s1.top();
                    s1.pop();
                    s1.push(y * x);
                }else if(s[i] == '/') {
                    int x = s1.top();
                    s1.pop();
                    int y = s1.top();
                    s1.pop();
                    s1.push(y / x);
                }else if(s[i] == '+') {
                    int x = s1.top();
                    s1.pop();
                    int y = s1.top();
                    s1.pop();
                    s1.push(y + x);
                }else {
                    cout << s1.top();
                    return 0;
                }
            }
        }
    }
    return 0;
}